﻿[output_none]

	[if:(action_param:'menuform_title')!='' && (action_param:'menuform_menu')!='' && (action_param:'menuform_lang')!='']
	
		[var:'del_menu'=(encode_sql:(action_param:'menuform_menu'))]
		[var:'del_lang'=(encode_sql:(action_param:'menuform_lang'))]
		[var:'del_title'=(encode_sql:(action_param:'menuform_title'))]
	
		<!-- menuid opzoeken  -->
			[var:'sql_search_menuid'='
				SELECT 		*
				FROM		SHb_menus
				WHERE		_k1_menuid	= \'' + $del_menu + '\'
			']
			
			[Inline: -database='SHoebox', -sql=$sql_search_menuid]
				[if:(error_currenterror:-errorcode)==0]
					[var:'found_page_id'=(field:'_k2_pageid')]
					[var:'output_error'='0']
				[else]
					[var:'output_error'='1']
				[/if]
			[/inline]
		
		
	
		<!-- delete menu translation -->
			[var:'sql_delete_menu_translation'='
				DELETE FROM	SHb_translations_menus
				WHERE		_k2_menuid		= \'' + $del_menu + '\'
				AND			_k2_languageid	= \'' + $del_lang + '\' ']
				
			[Inline: -database='SHoebox', -sql=$sql_delete_menu_translation]
				[if:(error_currenterror:-errorcode)==0]
					[var:'output_error'='0']
				[else]
					[var:'output_error'='1']
				[/if]
			[/inline]
			
			
			
		<!-- delete page translation -->
			[var:'sql_delete_page_translation'='
				DELETE FROM	SHb_translations_pages
				WHERE		_k2_pageid		= \'' + $found_page_id + '\'
				AND			_k2_languageid	= \'' + $del_lang + '\' ']
				
			[Inline: -database='SHoebox', -sql=$sql_delete_page_translation]
				[if:(error_currenterror:-errorcode)==0]
					[var:'output_error'='0']
				[else]
					[var:'output_error'='1']
				[/if]
			[/inline]
			
			
						
		<!-- delete menu -->
			[var:'sql_delete_menu'='
				DELETE FROM	SHb_menus
				WHERE		_k1_menuid	= \'' + $del_menu + '\'
				AND			_k2_pageid	= \'' + $found_page_id + '\' ']
				
			[Inline: -database='SHoebox', -sql=$sql_delete_menu]
				[if:(error_currenterror:-errorcode)==0]
					[var:'output_error'='0']
				[else]
					[var:'output_error'='1']
				[/if]
			[/inline]
			

	
		<!-- delete pages -->
			[var:'sql_delete_pages'='
				DELETE FROM	SHb_pages
				WHERE		_k1_pageid		= \'' + $found_page_id + '\' ']
				
			[Inline: -database='SHoebox', -sql=$sql_delete_pages]
				[if:(error_currenterror:-errorcode)==0]
					[var:'output_error'='0']
				[else]
					[var:'output_error'='1']
				[/if]
			[/inline]
			
	[else]
	
		[var:'output_error'='1']
		
	[/if]
	
	
	[if:(var:'output_error')==0]
		[var:'output_message'='Menu removed']
	[else]
		[var:'output_message'='An error occured while removing the menu']
	[/if]
	
	
[/output_none]
<b>[var:'output_message',-encodenone]</b>